Several commands are defined for use with the DiagramSurface control. You can send these commands to the DiagramSurface from whatever user interface you choose – menus, toolbars, keystrokes, etc. The built-in commands cover the following areas:
- Aligning nodes
- Distributing (spacing out) nodes
- Z-ordering nodes (bring forward / send backward)
- Size to fit
See the DiagramCommands class for the list of built-in commands. The DiagramSurface also responds to the built-in Delete, Undo, Redo and SelectAll commands.
To programatically send a command to a DiagramSurface, set the CommandTarget to the DiagramSurface control.
CopyAlignment commands on a toolbar
<ToolBar> <Button Command="ms:DiagramCommands.AlignLeft" CommandTarget="{Binding ElementName=ds}">Align Left</Button> <Button Command="ms:DiagramCommands.AlignCenter" CommandTarget="{Binding ElementName=ds}">Align Center</Button> <Button Command="ms:DiagramCommands.AlignRight" CommandTarget="{Binding ElementName=ds}">Align Right</Button> <Button Command="ms:DiagramCommands.AlignTop" CommandTarget="{Binding ElementName=ds}">Align Top</Button> <Button Command="ms:DiagramCommands.AlignMiddle" CommandTarget="{Binding ElementName=ds}">Align Middle</Button> <Button Command="ms:DiagramCommands.AlignBottom" CommandTarget="{Binding ElementName=ds}">Align Bottom</Button> </ToolBar> <ms:DiagramSurface Name="ds" />